#include <graphics.h>

void draw_arrow(float sx, float sy,
                float ex, float ey,
                float r, float len) {
	setcolor(EGEARGB(0xff, 0x0, 0xff, 0x0));
    setfillcolor(EGEARGB(0xff, 0x0, 0xff, 0x0));
    setlinewidth(6.0f);
    ege_line(sx, sy, ex, ey);
	ege_point points[3];
	points[0].x = ex;
	points[0].y = ey;
	if(sx == ex){
		if(sy > ey)
		{
			len = -len;
			points[0].y -= 2;
		}
		else
			points[0].y += 2;
		points[1].x = ex+r;
		points[1].y = ey-len;
		points[2].x = ex-r;
		points[2].y = ey-len;
	}
	else if(sy == ey){
		if(sx > ex)
		{
			len = -len;
			points[0].x -= 2;
		}
		else
			points[0].x += 2;
		points[1].x = ex-len;
		points[1].y = ey-r;
		points[2].x = ex-len;
		points[2].y = ey+r;
	}
    ege_fillpoly(3, points);
}